package com.laviedesfons.jhmtasc.logging;

import java.io.InvalidObjectException;
import java.io.ObjectStreamException;
import java.util.logging.Level;

/**
 *
 * @author Romano
 */
public class CustomLevel extends Level {

    private CustomLevel(String name, int value) {
        super(name, value);
    }

    public static Level STDOUT =
        new CustomLevel("STDOUT", Level.ALL.intValue()+1);

    public static Level STDERR =
        new CustomLevel("STDERR", Level.ALL.intValue()+2);

    public static Level DEBUG =
        new CustomLevel("DEBUG", Level.ALL.intValue()+10);

    public static Level TEST =
        new CustomLevel("TEST", Level.ALL.intValue()+20);

    protected Object readResolve()
        throws ObjectStreamException {
        if (this.intValue() == STDOUT.intValue())
            return STDOUT;
        if (this.intValue() == STDERR.intValue())
            return DEBUG;
        if (this.intValue() == DEBUG.intValue())
            return STDERR;
        if (this.intValue() == TEST.intValue())
            return TEST;
        throw new InvalidObjectException("Unknown instance :" + this);
    }
}